<template>
    <div>

        <van-nav-bar
                title="不凡"
                left-text="返回"
                @click-left="onClickLeft"
                  fixed
                placeholder 
                />
        <van-address-list
                    v-model="chosenAddressId"
                    :list="list"
                    default-tag-text="默认"
                    @add="onAdd"
                    @edit="onEdit"
                    />
    </div>
</template>

<script>
// import { Toast } from 'vant';
import {getListAction } from "../../../api/my/index.js"
    export default {
        data() {
            return {
                chosenAddressId:"",
                tagtext:"",
                 list: [ ],

                            
            }
        },
        methods: {
            onClickLeft(){
                    this.$router.go(-1)
            },
            onAdd(){
                    this.$router.push({path:"/addinput"})
            },
            onEdit(event){
                console.log(event.id);
                    this.$router.push({path:"/addinput",query:{id:event.id}})
            }

        },
        created(){
            var openId = localStorage.getItem("openId")
            getListAction({
                openId:openId
            }).then(res=>{
                console.log(res);
                res.data.forEach(el =>el.tel=el.mobile);
                res.data.forEach(el=>el.isDefault=el.is_default)
                this.list.push(...res.data)
                console.log(this.list);
            })
        }

    }
</script>

<style lang="scss" scoped>

</style>